//
//  LGBloodPressureHeader.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/3/6.
//

#import "LGBloodPressureHeader.h"


#define leftMargin   viewPix(58)
#define itemWidth    (Screen_W-viewPix(32)-leftMargin-viewPix(10))/4.0// viewPix(90)

@interface LGBloodPressureHeader()

/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIView *bottomView;
/**   */
@property (nonatomic , strong)UILabel *highLabel;
/**   */
@property (nonatomic , strong)UILabel *lowLabel;
/**   */
@property (nonatomic , strong)UILabel *heartLabel;
/**   */
@property (nonatomic , strong)UILabel *ecgLabel;

@end

@implementation LGBloodPressureHeader

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.clipsToBounds = YES;
        self.backgroundColor = [UIColor clearColor];
        [self addSubview:self.baseView];
        [self.baseView addSubview:self.monthLabel];
        [self.baseView addSubview:self.bottomView];
        [self.baseView addSubview:self.highLabel];
        [self.baseView addSubview:self.lowLabel];
        [self.baseView addSubview:self.heartLabel];
        [self.baseView addSubview:self.ecgLabel];
        
        [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(viewPix(5));
            make.left.bottom.equalTo(self).offset(viewPix(16));
            make.right.equalTo(self).offset(-viewPix(16));
        }];

        [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.baseView).offset(viewPix(38));
            make.left.bottom.right.equalTo(self.baseView);
        }];
        [self.highLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.baseView).offset(leftMargin);
            make.top.equalTo(self.baseView).offset(viewPix(46));
            make.width.equalTo(@(itemWidth));
            make.height.equalTo(@(viewPix(22)));
        }];
        [self.lowLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.highLabel.mas_right);
            make.centerY.width.height.equalTo(self.highLabel);
        }];
        [self.heartLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lowLabel.mas_right);
            make.centerY.width.height.equalTo(self.highLabel);
        }];
        [self.ecgLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.heartLabel.mas_right);
            make.centerY.width.height.equalTo(self.highLabel);
        }];
    }
    return self;
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:8];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UILabel *)monthLabel{
    if(!_monthLabel){
        _monthLabel = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
        _monthLabel.frame = CGRectMake(viewPix(12), viewPix(10), viewPix(150), viewPix(22));
    }
    return _monthLabel;
}


-(UIView *)bottomView{
    if(!_bottomView){
        _bottomView = [[UIView alloc] init];
        _bottomView.backgroundColor = [UIColor colorWithString:@"#F5FBFF"];
    }
    return _bottomView;
}

-(UILabel *)highLabel{
    if(!_highLabel){
        _highLabel = [UILabel lableWithText:@"高压" colorString:@"#606266" textFont:LGFont(16) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _highLabel;
}

-(UILabel *)lowLabel{
    if(!_lowLabel){
        _lowLabel = [UILabel lableWithText:@"低压" colorString:@"#606266" textFont:LGFont(16) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _lowLabel;
}

-(UILabel *)heartLabel{
    if(!_heartLabel){
        _heartLabel = [UILabel lableWithText:@"心率" colorString:@"#606266" textFont:LGFont(16) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _heartLabel;
}

-(UILabel *)ecgLabel{
    if(!_ecgLabel){
        _ecgLabel = [UILabel lableWithText:@"心电图" colorString:@"#666666" textFont:LGFont(16) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _ecgLabel;
}

@end
